import request from '@/utils/request'

export function mqjc(project_id, params) {
  return request({
    url: `/api/device/mqjc/${project_id}`,
    method: 'get',
    params
  })
}

export function getAll(params) {
  return request({
    url: '/api/device',
    method: 'get',
    params
  })
}

export function getOne(id) {
  return request({
    url: `/api/device/select/${id}/cloud`,
    method: 'get'
  })
}

export function addOne(data) {
  return request({
    url: '/api/device',
    method: 'post',
    data
  })
}

export function updateOne(id, data) {
  return request({
    url: '/api/device/' + id,
    method: 'put',
    data
  })
}

export function deleteOne(id) {
  return request({
    url: '/api/device/' + id,
    method: 'delete'
  })
}

export function sendCommand(data, serialno) {
  return request({
    url: '/api/device/' + serialno + '/sendCommand',
    method: 'post',
    data
  })
}

export function sendCommands(data, serialno) {
  return request({
    url: '/api/device/' + serialno + '/sendCommands',
    method: 'post',
    data
  })
}

export function sendPWM(data) {
  return request({
    url: '/api/device/pwm',
    method: 'post',
    data
  })
}

export function startHanterDrip(data) {
  return request({
    url: `https://maec.intelirri.com/v1/hunter/start`,
    method: 'post',
    data
  })
}

export function stopHanterDrip() {
  return request({
    url: `https://maec.intelirri.com/v1/hunter/stop`,
    method: 'post'
  })
}

export function getDevicesStates(data) {
  return request({
    url: '/api/devices/states',
    method: 'post',
    data
  })
}

export function selectForCloud(params) {
  return request({
    url: '/api/device/select/cloud',
    method: 'get',
    params
  })
}

export function selectOneForCloud(serialno) {
	return request({
	  url: `/device/select/${serialno}/cloud`,
	  method: 'get'
	})
}

export function updateRtuPortDisplays(data, serialno) {
  return request({
    url: `/api/device/${serialno}/rtuPortDisplays`,
    method: 'put',
    data
  })
}

export function restartGw(serialno) {
  return request({
    url: `/api/device/restartGw/${serialno}`,
    method: 'get'
  })
}

export function setOne(serialno, data) {
  return request({
    url: `/idata/device/${serialno}/set`,
    method: 'put',
    data
  })
}

export function readOne(serialno,params) {
  return request({
    url: `/idata/device/${serialno}`,
    method: 'get',
    params
  })
}
